package com.bigshen.demo.annotation.configurecomponents.a3Lazy;

import com.bigshen.demo.project.entity.Person;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

@Configuration
public class MyConfig {

    /**
     * Lazy 只针对单例bean起作用
     * 默认不写Lazy，非懒加载，即在Spring容器初始化时就将对象创建出来；
     * 加上Lazy 会懒加载
     * @return
     */
    @Lazy
    @Bean
    public Person person222() {
        System.out.println("创建person对象");
        return new Person("Shen", "18");
    }

}
